class Solution {
public:
    vector<int> resultsArray(vector<int>& nums, int k) {
        if (k == 1)
            return nums;
        int n = nums.size(), left = 0, right = 1;
        vector<int> ans(n - k + 1);
        for (; right < n; right++) {
            if (nums[right] != nums[right - 1] + 1)
                left = right;

            if (right - left >= k - 1) {
                ans[right - k + 1] = nums[right];
            } else if (right + 1 >= k) {
                ans[right - k + 1] = -1;
            }
        }
          return ans;
    }
}
;